﻿using System;

namespace Coding4Fun.BoxingBots.Robot
{
	public struct SensorData
	{
		public bool IsRightSwitchTriggered { get; set; }
		public bool IsLeftSwitchTriggered { get; set; }

		public bool IsSwitchTriggered
		{
			get { return IsRightSwitchTriggered && IsLeftSwitchTriggered; }
		}

		public double RawTopRight { get; set; }
		public double RawTopLeft { get; set; }
		public double RawBottomRight { get; set; }
		public double RawBottomLeft { get; set; }

		public double TopRight { get { return CalculatedValue(RawTopRight); } }
		public double TopLeft { get { return CalculatedValue(RawTopLeft); } }
		public double BottomRight { get { return CalculatedValue(RawBottomRight); } }
		public double BottomLeft { get { return CalculatedValue(RawBottomLeft); } }

		public double CalculatedValue(double rawValue)
		{
			if ((rawValue < 530) && (rawValue > 80))
				return Math.Round(2076 / (rawValue - 11.0), 2);

			return -1;
		}
	}
}
